﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UAC;

namespace UACManager
{
    public partial class TeamRoleDefForm : Form
    {
        private int teamDefId;
        public TeamRoleDefForm(int teamDefId)
        {
            InitializeComponent();
            this.teamDefId = teamDefId;
        }

        private void TeamRoleDefForm_Load(object sender, EventArgs e)
        {
            this.Text = string.Format("添加TeamRoleDef - {0}", this.teamDefId);
            this.tTeamDefID.Text = this.teamDefId.ToString();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string _teamRoleDefID = this.tTeamRoleDefID.Text;
            string _name = this.tName.Text;
            string _description = this.tDesc.Text;

            if (string.IsNullOrEmpty(_teamRoleDefID) || string.IsNullOrEmpty(_name))
            {
                MessageBox.Show("为空！", "警告");
                return;
            }
            int teamRoleDefID;
            if (!int.TryParse(_teamRoleDefID, out teamRoleDefID))
            {
                MessageBox.Show("TeamRoleDefID格式错误！", "警告");
                return;
            }
            try
            {
                Utils.CreateTeamRoleDef(teamRoleDefID, this.teamDefId, _name, _description, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告");
                return;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
